﻿using System;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using Aquarinum.Base.Infrastructure.EventBus.RabbitMQWrapper;
using EasyNetQ;
using Nl.Mq.Domain;
using Nl.RabbitMq.Demo.EasyNetQWrapper;

namespace Nl.RabbitMq.Demo.Receiver
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                RabbitMqClient client = new RabbitMqClient(@"host=localhost");

                //client.AutoSubscribe("Nl.Mq.Domain", "test", "Test*");
                client.Receive<MqExcepotionMessage>("MQErrorQueue",
                    msg =>
                    {
                        Console.WriteLine(msg.Message);
                    });
                RabbitMqClient client2 = new RabbitMqClient(@"host=localhost");
                client2.Subscribe<TestAckMessage>("yan",
                    msg =>
                    {
                        throw new Exception("testreerror");
                    });


                //client2.Subscribe<MqExcepotionMessage>("errorhandle",
                //    message =>
                //    {
                //        Console.WriteLine(message.Message);
                //    });


            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }

            Console.Read();

            //client.AutoSubscribe(Assembly.GetExecutingAssembly().FullName , Assembly.GetExecutingAssembly().FullName, "");
        }
    }

    //public class TestAckMessage
    //{
    //    public string msg { get; set; }
    //}
}